package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;

/**
 * Controller class for the address book
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class AddressCtr
{

    private AddressBook aBook;
    
    public AddressCtr(/*---*/)
    {
        aBook = new AddressBook();
    }

    public Person readPerson(String name)
    {
        Person p = aBook.readPerson(name);
        return p;
    }
    
    
    public void createPerson(String name, String address, String postalCode, String city, int phoneNo)
    {   
       //creates a Person object and stores it in the container
       Person p = new Person(name, address, postalCode, city, phoneNo);
       aBook.addPerson(p);
    }
    
    public void deletePerson(String name)
    {
        Person p = aBook.getPerson(name);
        aBook.removePerson(p);
    }
    
    public void updatePerson(String name, String address, String postalCode, String city, int phoneNo)
    {
        aBook.updatePerson(name, address, postalCode, city, phoneNo);
    }
    public ArrayList<Person> listAllPersons()
    {
        ArrayList<Person> p = aBook.listAllPersons();
        return p;
    }
}
